#pragma once
#include"Common.h"
#include"ObjectPool.h"
#include<mutex>
class PageCache{
    private:
        SpanList _spanLists[MAX_SPANS];
        static PageCache _instan;
        PageCache(){}
        PageCache(const PageCache&)=delete;
        PageCache& operator=(const PageCache&)=delete;
        std::mutex mtx;
        ObjectPool<Span> _spanPool;
    public:
        std::mutex _pagemtx;
        static PageCache* Instance(){
            return &_instan;
        }
        Span*newpage(size_t K);
        std::unordered_map<PageID,Span*> _idSpanmap;
        //std::unordered_map<PageID,size_t> _objSpanmap;
        Span*MapObjectTospan(void*obj);
        //将span从spanlist中移除
       void ReleaseToPageCache(Span* span);
};